<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link th:href="@{/css/bootstrap.min.css}" href="../static/css/bootstrap.min.css" rel="stylesheet">
    <title>books</title>
</head>
<body>
<h1>Books List</h1>
<div class="container">
    <h2 class="page-header">书单列表</h2>
    <div class="alert alert-success alert-dismissable fade in" th:unless="${#strings.isEmpty(message)}">
        <a href="#" class="close" data-dismiss="alert">&times;</a>
        <strong>恭喜，</strong>
        <span th:text="${message}">信息提交成功</span>
    </div>
    <p class="text-right"><a href="./input.html" th:href="@{/books/input}" class="btn bg-primary">新增</a></p>
    <table class="table table-bordered table-striped table-hover">
        <thead>
        <tr>
            <th>#</th>
            <th>书名</th>
            <th>作者</th>
            <th>说明</th>
            <th>状态</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        <!--
        iterStat:
            count: 计数
            index: 索引 从零开始
            size: 列表总条数
            even/odd: 偶数奇数
            first/last: 第一条/最后一条
        -->
        <!--<tr th:each="book,iterStat:${books}" th:class="${iterStat.even}? 'bg-danger':'bg-success'">-->
        <!--<tr th:each="book,iterStat:${books}">-->
        <tr th:each="book,iterStat:${books.content}">
            <td th:text="${iterStat.count}">1</td>
            <!--<td><a href="#" th:text="${book.name}" th:href="@{/books/{id}(id=${book.id})}">11</a></td>-->
            <td><a href="#" th:text="${book.name}" th:href="@{'/books/' + ${book.id}}">11</a></td>
            <td th:text="${book.author}">111</td>
            <td th:text="${book.description}">1111</td>
            <td th:switch="${book.status}">
                <span th:case="0">未读</span>
                <span th:case="1">在读</span>
                <span th:case="2">已读</span>
                <span th:case="*">未配置</span>
            </td>
            <td>
                <a href="#" th:href="@{/books/input/{id}(id=${book.id})}">编辑</a>&nbsp;
                <a href="#" th:href="@{/books/{id}/delete(id=${book.id})}">删除</a>
            </td>
        </tr>
        </tbody>
    </table>
    <nav>
        <ul class="pager">
            <li class="previous"><a href="#" th:href="@{'/books?page='+${books.number-1}}" th:unless="${books.first}">上一页</a>
            </li>
            <li class="next"><a href="#" th:href="@{/books(page=${books.number} + 1)}" th:unless="${books.last}">下一页</a>
            </li>
        </ul>
    </nav>
</div>
</body>
<script th:src="@{/js/jquery.min.js}" src="../static/js/jquery.min.js"></script>
<script th:src="@{/js/bootstrap.min.js}" src="../static/js/bootstrap.min.js"></script>
</html>